package com.ycsj.goldmedalnewconcept.utils;

import java.util.HashMap;
import java.util.Map;

import android.R.integer;
import android.R.string;

import com.iflytek.speech.VoiceWakeuperAidl;
import com.ycsj.goldmedalnewconcept.bean.AnswerInfo;

/**
 * 用于保存答题题目的帮助类
 * 
 * @author Administrator
 *
 */
public class AnswerManager {
	// 单例
	private static volatile AnswerManager manager;

	// 用于保存答题答案的Map集合
	private static Map<Integer, AnswerInfo> map;

	// 私有化构造函数
	private AnswerManager() {
		map = new HashMap<>();
	}

	// 提供获取单例的方法
	public static AnswerManager getInstance() {
		if (manager == null) {
			synchronized (AnswerManager.class) {
				if (manager == null) {
					manager = new AnswerManager();
				}
			}
		}
		return manager;
	}

	/**
	 * 返回给外部的方法
	 * 
	 * @return
	 */
	public static Map<Integer, AnswerInfo> getAnserMap() {
		return map;
	}

	/**
	 * 添加答题题目的方法
	 */
	public static void addAnswer(int pos, AnswerInfo answerInfo) {
		if (map != null) {
			map.put(pos, answerInfo);
		}
	}

	/**
	 * 录音后重新修改对应位置的分数信息
	 */
	public static void upDateAnswer(int pos, float b, String audioPath) {
		AnswerInfo info = map.get(pos);
		info.score = b;
		info.audioPath = audioPath;
//		info.setScore(b);
//		info.setAudioPath(audioPath);
	}
}
